// https://iai.sh.cn/problem/364
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int total = 0, today = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'Y') {
      today++;
      if (today > 5)
        today = 5;
    } else {
      today = 0;
    }
    total += today;
  }
  cout << total;
  return 0;
}